import request from '@/utils/request'
const UpmsNoticeService = {
  state: {},

  mutations: {},

  actions: {
    // 根据主键获取详情
    getNoticeById({ commit }, id) {
      return new Promise((resolve, reject) => {
        request.get('notice/getById/' + id).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    /**
     * 通知公告分页
     */
    noticePage({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.get('notice/page', params).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },

    /**
     * 通知公告保存
     */
    noticeSave({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.post('notice/save', params).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    /**
     * 通知公告更新
     */
    noticeUpdate({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.post('notice/update/' + params.id, params).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    /**
     * 更改发送状态
     */
    noticeChangeSendStatus({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.post('notice/changeSendStatus/' + params.id, params.sendStatus).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    /**
     * 通知公告删除
     */
    noticeRemove({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.post('notice/remove', params).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    }
  }
}

export default UpmsNoticeService
